<txp:rvm_privileged /> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAhi6oWJFOt_kzphrlbscTVRTjuMK8MxY749wLvVVEE-IhVVTD4RQKatG1xolq58x9qme2YqKO4E0Vbw"></script>
<script src="\textpattern\jquery.js"></script>
<script type="text/JavaScript">
var txpData;
function log(message){
//$("#log").html($("#log").html()+message+"\n");
}
</script>
<script type="text/javascript">
var map;
var prevLat;
var prevLng;
var combinedMarkerData;

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
};

$(document).ready(function() {
  var mypoint;
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setUIToDefault();
        //flickr
        $.getJSON(   
            'http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=91be33f6e20a2ec253d0b4dfd25263c5&user_id=24394299%40N06&extras=geo&format=json&jsoncallback=?',   
            function(data) {           
              log("Loading Flickr Markers");
              for (var i=0; i < data.photos.total; i++){
                var photo = data.photos.photo[i];
                var title = photo.title;
                var url = 'http://farm'+
                    photo.farm+
                    '.static.flickr.com/'+
                    photo.server+
                    '/'+
                    photo.id+
                    '_'+
                    photo.secret+
                    '_m.jpg';
                var pageUrl = 'http://www.flickr.com/photos/24394299%40N06/'+photo.id;
                var lat = photo.latitude;
                var lng = photo.longitude;
                if (lat!=0 && lng!=0){
                  log(buildHtml('Flickr',pageUrl,url,'NA')+lat+','+lng);
                  if (lat==prevLat && lng==prevLng){
                    log("adding to combinedMarkerData");
                    if (combinedMarkerData!=null){
                      combinedMarkerData+=buildHtml('Flickr',pageUrl,url,'NA');
                    }else{
                      combinedMarkerData=buildHtml('Flickr',pageUrl,url,'NA');                
                    }
                  }else{
                    if (combinedMarkerData!=null&&prevLat!=null&&prevLng!=null){
                      //add combinedMarker
                      var myCombinedFlickrPoint = new GLatLng(prevLat,prevLng);
                      map.addOverlay(createMarker(myCombinedFlickrPoint,combinedMarkerData, map));
                      combinedMarkerData = null;
                      log("set marker for combinedMarkerData");
                    }
                    var myFlickrPoint= new GLatLng(lat,lng);
                    var markerHtml = buildHtml('Flickr',pageUrl,url,'NA');
                    map.addOverlay(createMarker(myFlickrPoint,markerHtml, map));
                    $.preloadImages(url);
                  }
                  prevLat = lat;
                  prevLng = lng;              
                }
                if (combinedMarkerData!=null&&prevLat!=null&&prevLng!=null){
                  //add combinedMarker
                  var myCombinedFlickrPoint = new GLatLng(prevLat,prevLng);
                  map.addOverlay(createMarker(myCombinedFlickrPoint,combinedMarkerData, map));
                  combinedMarkerData = null;
                  log("set marker for combinedMarkerData");
                }
          }
    }
    );//end getJSON(flickr)
}
});//end document ready


function createMarker(point, message, map) {
  var marker = new GMarker(point);
  map.setCenter(point, 8);
  GEvent.addListener(marker, "click", function() {
    var myHtml = message;
    map.openInfoWindowHtml(point, myHtml);
  });
  return marker;
}
function buildHtml(source,permalink,image,posted){
var imageHtml='<table>'+
       '<tr>'+
       '<td style=\"padding: 0 5px\">'+
       '<a href=\"'+permalink+'\">'+
       '<img src="'+image+'" class="article-image" />'+
       '</a>'+
       '</td>'+
       '<td valign=\"top\">';
if (posted!='NA'){
imageHtml+='<font color=\"#6B6B6B\">Date: </font>'+
       '<font color=\"#333333\">'+posted+'</font>'+
       '<br/>';
}
imageHtml+='<p>'+
       '<a href=\"'+permalink+'\">'+
       '<font color=\"#3964C2\">View '+source+' Photo</font>'+
       '</a>'+
       '</p>'+
       '</td>'+
       '</tr>'+
       '</table>';
return imageHtml;
}

</script>
<title></title> 
</head>

<body>
<div id="map_canvas" style="width: 650px; height: 500px;"></div>
<div id="log"></div>
<div id="images"></div>
</body>
</html>